package trunk.backend;

import java.util.ArrayList;

public class PageWriter {
	private ArrayList<String> page;
	private String endString;
	
	public PageWriter() {
		page = new ArrayList<String>();
		page.add("<html>\n<body>\n");
		endString = "</body>\n</html>";
	}
	
	public void addLabel(String labelText, boolean newLine) {
		if (newLine) page.add(labelText + "\n<br />\n");
		else page.add(labelText + "\n");
	}
	
	public void addTextBox(String name) {
		page.add("<input type=\"text\" name=" + name + "\" />\n<br />\n");
	}
	
	public void addRadioButton(String name, ArrayList<String> labels, boolean vertical) {
		String radioButtons = "";
		for (String s : labels) {
			radioButtons += "<input type=\"radio\" name=" + name + "\" ";
			radioButtons += "value=\"" + s + "\" /> " + s + "\n";
			if (vertical) radioButtons += "<br />\n";
		}
		page.add(radioButtons);
	}
	
	public void addCheckBoxes(String name, ArrayList<String> labels, boolean vertical) {
		String checkBoxes = "";
		for (String s : labels) {
			checkBoxes += s + "\n";
			checkBoxes += "<input type=\"checkbox\" name=" + name + "\" ";
			checkBoxes += "value=\"" + s + "\" /> \n";
			if (vertical) checkBoxes += "<br />\n";
		}
		page.add(checkBoxes);
	}
}
